/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton, CColumn } from '../../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Http, Toast } from '../../../library/func';
import Icon from '../../../project/style/icon';

/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class SalesList extends Component {

	/*------------------------------------------------------------------------------------
	 * 初始化
	 *-----------------------------------------------------------------------------------*/
	constructor(props) {
		super(props);

		/**
		 * state
		 */
		this.state = {
			text: props.initialValue || 'placeholder'
		}
	}

    /*------------------------------------------------------------------------------------
	 * 事件处理
	 *-----------------------------------------------------------------------------------*/
    // onRedirect
    onRedirect = (url, e)=> {
        wx.redirectTo({
            url: url
        })
    }

    // onNavigate 跳转到详情
	onNavigate = (url, e)=> {
		wx.navigateTo({
			url: url
		})
	}

    /*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/
    // Toast
    toToast = ()  => {
        Toast.text('暂未开放此功能')
    }


	/*------------------------------------------------------------------------------------
	 * 渲染
	 *-----------------------------------------------------------------------------------*/
	render () {
        const time = new Date(this.props.data.time*1000);
        const timeString = time.getFullYear()+'-'+(time.getMonth()+1)+'-'+time.getDate()+' '+time.getHours()+':'+time.getMinutes()+':'+time.getSeconds()
		return (
			<CRow bg='#fff' px='24' mx='10' pb='20' pt='6' ra='8' mb='20'>
                <CColumn>
                    <CBetween py='16' mb='20'
                        onClick={this.onNavigate.bind(this,'/screen/vip/vip/settlement?id='+this.props.data.id)}
                    >
                        <CHand size='24' color='#7b7b7b'>{timeString}</CHand>
                        <CSvg w='24' h='24' color='#c3c3c3' icon={Icon.right} />
                    </CBetween>
                    <CItemX class='w1' style='width:100%'>
                        <CHand>
                            <CImage w='200' h='200' mr='20' src='http://image.cdn.hesq.com.cn/rushbuy/product/{{this.props.data.img}}' />
                        </CHand>
                        <CItemY x='left' h='260' class='f1' style='flex:1'>
                            <CHand class='textOver' size='28' mb='15' h='72' color='#373737' oh>{this.props.data.name}</CHand>
                            <CColumn >
                                <CHand size='28' color='#373737' mr='20'>￥{this.props.data.price}</CHand>
                                <CHand size='24' color='#373737' mt='4'>预估收入 ￥{this.props.data.prediction}</CHand>
                            </CColumn>
                            <CBetween class='w1'>
                                <CHand size='24' class='w04' ba='1 solid #9f9f9f' ra='8' bg='#fff' color='#7b7b7b' pa='14 28' 
                                    onClick={this.toToast}
                                >查看物流</CHand>
                                <CHand size='24' class='w04' ba='1 solid #9f9f9f' ra='8' bg='#fff' color='#7b7b7b' pa='14 16'
                                    onClick={this.onRedirect.bind(this,'/screen/vip/vip/fans/detail?id='+this.props.data.fkuid)}
                                >查看买家信息</CHand>
                            </CBetween>
                        </CItemY>
                    </CItemX>
                </CColumn>
            </CRow>
		)
	}
}


